$(function() {
	$(".menu-check").click(function(){
		var pid=$(this).attr("data-pid");
		var id = $(this).val();
		var ischecked = $(this).is(':checked');
		var checked_ids = [];
		$(".menu-check-"+pid+":checked").each(function(){
			checked_ids.push($(this).val());
		});
		if(checked_ids.length == 0){
			$("#pmenu-"+pid).val("");
		} else{
			$("#pmenu-"+pid).val(pid);
		}
	});
	$("#sub-btn").click(function(){
		if($("#rolename").val() == ""){
			alert("请先填写角色名称");
			return;
		}
		$("#role-form").submit();
	});
	/*删除角色*/
	$('.role-delete').on('click', function() {
		$('#del-confirm').modal({
			relatedTarget : this,
			onConfirm : function(options) {
				var id = $(this.relatedTarget).attr("data-id");
				window.location="deleteRole?id=" + id;
			},
			// closeOnConfirm: false,
			onCancel : function() {

			}
		});
	});
});